# 导包
from django.conf import settings
from django.core.files.storage import Storage
# 继承类



class FastDFSStorage(Storage):
    """自定义文件存储系统，修改存储的方案"""
    def __init__(self, fdfs_base_url=None):
        """
        构造方法，可以不带参数，也可以携带参数
        :param base_url: Storage的IP
        """
        self.fdfs_base_url = fdfs_base_url or settings.FDFS_BASE_URL
    # _open
    def _open(self, name, mode='rb'):
        pass
    # _save
    def _save(self, name, content, max_length=None):
        pass
    # url
    def url(self, name):
        """
        返回name所指文件的绝对URL
        :param name: 要读取文件的引用:group1/M00/00/00/wKhnnlxw_gmAcoWmAAEXU5wmjPs35.jpeg
        :return: http://192.168.103.158:8888/group1/M00/00/00/wKhnnlxw_gmAcoWmAAEXU5wmjPs35.jpeg
        """
        # http://192.168.90.172:8888/ ---我们自己添加本地域名
        # group1/M00/00/00/CtM3BVnifxeAPTodAAPWWMjR7sE487.jpg == name
        return self.fdfs_base_url + name